<template>
  <div id="main" :style="{height: '100%',width: '100%',position: 'absolute' }"></div>
</template>
<script>

import * as echarts from 'echarts';

export default {
    data(){
        return {
            
        }
    },
    mounted(){
        this.show(this.$route.query);
    },
    methods:{
        show(row){
            console.log(row)
            var chartDom = document.getElementById('main');
            var myChart = echarts.init(chartDom);
            var option;
            var years = [];
            for(var i = 0; i <= row.year * 12; i++){
                years[i] = i  + "月";
            }
            option = {
                title: {
                    text: '折旧变化图',
                },
                tooltip: {
                    trigger: 'axis'
                },
                legend: {
                    data: ['预计净值', '']
                },
                toolbox: {
                    show: true,
                    feature: {
                        dataZoom: {
                            yAxisIndex: 'none'
                        },
                        dataView: {readOnly: false},
                        magicType: {type: ['line', 'bar']},
                        restore: {},
                        saveAsImage: {}
                    }
                },
                xAxis: {
                    type: 'category',
                    boundaryGap: false,
                    data: years
                },
                yAxis: {
                    type: 'value',
                    axisLabel: {
                        formatter: '{value} 元'
                    }
                },
                series: [
                    {
                        name: '预计净值',
                        type: 'line',
                        data: row.priceList,
                        markPoint: {
                            data: [
                                {type: 'max', name: '最大值'},
                                {type: 'min', name: '最小值'}
                            ]
                        },
                        markLine: {
                            data: [
                                {type: 'average', name: '平均值'}
                            ]
                        }
                    }
                ]
            };

            option && myChart.setOption(option);
        }
    }
};
</script>